package com.blb.service.impl;

import com.blb.entity.Label;
import com.blb.mapper.LabelMapper;
import com.blb.service.ILabelService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lifeng
 * @since 2019-12-20
 */
@Service
public class LabelServiceImpl extends ServiceImpl<LabelMapper, Label> implements ILabelService {
    @Resource
    private LabelMapper labelMapper;

    /**
     * 查看标签列表
     * @param userId
     * @return
     */
    @Override
    public List<Label> listLabel(String userId) {
        return labelMapper.listLabel(userId);
    }

    /**
     * 删除标签 返回标签id
     * @param labelName
     * @param userId
     */
    @Override
    public String delGetLabelId(String labelName, String userId) {
        return labelMapper.delGetLabelId(labelName,userId);
    }
    /**
     * 删除关系标签中
     * @param labelId
     */
    @Override
    public void delLabel2(String labelId, String notesId) {
        labelMapper.delLabel2(labelId,notesId);
    }
    /**
     * 重命名标签
     * @param label
     */
    @Override
    public void updateLabel(Label label) {
        labelMapper.updateLabel(label);
    }

    /**
     * 通过labelId找到noteId
     * @param labelId
     * @return
     */
    @Override
    public List<String> byLabelGetNote(String labelId) {
        return labelMapper.byLabelGetNote(labelId);
    }

    /**
     * 通过noteId找到LabelId
     * @param notesId
     * @return
     */
    @Override
    public List<String> byNoteGetLabels(String notesId) {
        return labelMapper.byNoteGetLabels(notesId);
    }
    /**
     * 通过笔记名找到笔记id
     * @param notesName
     * @return
     */
    @Override
    public String byNoteNameGetNoteId(String notesName,String userId) {
        return labelMapper.byNoteNameGetNoteId(notesName,userId);
    }
    /**
     * 查看是否存在该标签
     * @param labelName
     * @param userId
     * @return
     */
    @Override
    public String getLabel2(String labelName, String userId) {
        return labelMapper.getLabel2(labelName,userId);
    }

    /**
     * 删除关系标签中的labelId
     * @param labelId
     */
    @Override
    public void delNoteLabelByLabel(String labelId) {
        labelMapper.delNoteLabelByLabel(labelId);
    }
    /**
     * 查看关系表是否有当前关系
     * @param labelId
     * @param notesId
     * @return
     */
    @Override
    public String getRelation(String labelId, String notesId) {
        return labelMapper.getRelation(labelId,notesId);
    }



    //手机端方法---------------------------------

    @Override
    public List<Label> MyLabelList(String userId) {
        return labelMapper.MyLabelList(userId);
    }

    @Override
    public List<Label> thisLabelid(String notesId) {
        return labelMapper.thisLabelid(notesId);
    }

    @Override
    public void updateById(String id, String labelName) {
        labelMapper.updateById(id,labelName);
    }

    @Override
    public void addThisLabel(String id,String labelId,String notesId,String userId) {
        labelMapper.addThisLabel(id,labelId,notesId,userId);
    }

    @Override
    public void delThisLabel(String labelId, String notesId) {
        labelMapper.delThisLabel(labelId,notesId);
    }

    //手机端方法---------------------------------

}
